From: Andrew Cooper Date: Mon, 25 Nov 2013 11:12:50 +0000 (+0000) Subject: tools/libxl: Avoid deliberate NULL pointer dereference X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5872 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=1677af03c14f2d8d88d2ed9ed8ce6d4906d19fb4;p=xen.git tools/libxl: Avoid deliberate NULL pointer dereference Coverity ID: 1055290 Calling LIBXL__LOG_ERRNO(ctx,) with a ctx pointer we have just failed to allocate is going to end badly. Opencode a suitable use of xtl_log() instead. Signed-off-by: Andrew Cooper CC: Ian Campbell Acked-by: Ian Jackson --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 9b932628e1..6263d14242 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -31,7 +31,9 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, ctx = malloc(sizeof(*ctx)); if (!ctx) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to allocate context\n"); + xtl_log(lg, XTL_ERROR, errno, "libxl", + "%s:%d:%s: Failed to allocate context\n", + __FILE__, __LINE__, __func__); rc = ERROR_NOMEM; goto out; }